﻿@using NetCoreCMS.Models;
@using NetCoreCMS.Common;
@inject NetCoreCMS.IServices.IUsersService _users;
@{
    Layout = "~/Areas/admin/Views/Shared/_LayoutList.cshtml";
    ViewBag.Title = "会员列表";
    List<Users> list = ViewData["list"] as List<Users>;
     List<SelectListItem> userListItems = ViewData["userListItems"] as List<SelectListItem>;
}
<script>
    //查询数据
    function search() {
        var text = $("#txtKeywords").val();
        var pageCount = $("#txtPageNum").val();
        var groupId = $("#ddlUserId").val();
        document.location = "index?keywords=" + text + "&pagesize=" + pageCount + "&ddlUserId=" + groupId;
    }

    //ExePostBack回调函数
    function __doPostBack(objId) {
        if (objId == "btnAudit") {
            submitAudit();
        }
        if (objId == "btnPass") {
            submitPass();
        }
        if (objId == "btnLock") {
            submitLock();
        }
        if (objId == "btnJiangjin") {
            submitJiangjin();
        }
        if (objId == "btnShare") {
            submitShare();
        }
        if (objId == "btnKong") {
            submitKong();
        }
    }

    //从游客转为贵宾只能单向
    function submitAudit() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitAudit?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
    //激活成有效贵宾先设置推荐人
    function submitPass() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitPass?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
    //锁定贵宾一切权益
    function submitLock() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitLock?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
    //停止贵宾各种资金制度
    function submitJiangjin() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitJiangjin?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
    //禁止贵宾推荐人
    function submitShare() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitShare?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
    //设置为空点位不向上级产生资金
    function submitKong() {
        var text = $("#txtKeywords").val();
        var $row = $("#ltable tr:gt(0)");
        var json = { list: [] };
        $($row).each(function (i, item) {
            if ($(item).find("input:checkbox").prop("checked")) {
                var id = $(item).find("td:eq(0)").find("label:eq(0)").text();
                var obj = { id: id };
                json.list.push(obj);
            }
        });
        $.ajax({
            url: "SubmitKong?keywords=" + text,
            type: "POST",
            dataType: "html",
            data: "json=" + JSON.stringify(json),
            success: function (data) {
                eval(data);
            },
            error: function () {
                alert("error");
            }
        });
    }
</script>
<form id="form1" method="post" action="#">
    <!--导航栏-->
    <div class="location">
        <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
        <a href="../center/index"><i class="iconfont icon-home"></i><span>首页</span></a>
        <i class="arrow iconfont icon-arrow-right"></i>
        <span>会员列表</span>
        <i class="arrow iconfont icon-arrow-right"></i>
        <span>会员列表</span>
    </div>
    <!--/导航栏-->
    <!--工具栏-->
    <div id="floatHead" class="toolbar-wrap">
        <div class="toolbar">
            <div class="box-wrap">
                <a class="menu-btn"><i class="iconfont icon-more"></i></a>
                <div class="l-list">
                    <ul class="icon-list">
                        <li><a href="javascript:;" onclick="checkAll(this);"><i class="iconfont icon-check"></i><span>全选</span></a></li>
                        <li><a href="javascript:;" id="btnAudit" class="lock" onclick="ExePostBack('btnAudit','从游客转为贵宾只能单向，是否继续？');"><i class="iconfont icon-survey"></i><span>贵宾</span></a></li>
                        <li><a href="javascript:;" id="btnPass" class="lock" onclick="ExePostBack('btnPass','激活成有效贵宾先设置推荐人，是否继续？');"><i class="iconfont icon-survey"></i><span>激活</span></a></li>
                        <li><a href="javascript:;" id="btnLock" class="lock" onclick="ExePostBack('btnLock','锁定贵宾一切权益，是否继续？');"><i class="iconfont icon-survey"></i><span>锁定</span></a></li>
                        <li><a href="javascript:;" id="btnJiangjin" class="lock" onclick="ExePostBack('btnJiangjin','停止贵宾各种资金制度，是否继续？');"><i class="iconfont icon-survey"></i><span>停奖</span></a></li>
                        <li><a href="javascript:;" id="btnShare" class="lock" onclick="ExePostBack('btnShare','禁止贵宾推荐人，是否继续？');"><i class="iconfont icon-survey"></i><span>发展</span></a></li>
                        <li><a href="javascript:;" id="btnKong" class="lock" onclick="ExePostBack('btnKong','设置为空点位不向上级产生资金，是否继续？');"><i class="iconfont icon-survey"></i><span>空点</span></a></li>
                    </ul>
                    <div class="menu-list">
                        <div class="rule-single-select">
                            @Html.DropDownList("ddlUserId", new SelectList(userListItems, "Value", "Text", ViewBag.userStatus), new { onchange = "search();" })
                        </div>
                    </div>
                </div>
                <div class="r-list">
                    <input type="text" id="txtKeywords" class="keyword" value="@ViewBag.Keywores" />
                    <a href="javascript:search()" id="lbtnSearch" class="btn-search"><i class="iconfont icon-search"></i></a>
                </div>
            </div>
        </div>
    </div>
    <!--/工具栏-->
    <!--列表-->
    <div class="table-container">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable" id="ltable">
            <tr>
                <th width="6%">选择</th>
                <th align="left">用户名</th>
                <th align="left" width="8%">直推人</th>
                <th align="left" width="8%">节点人</th>
                <th align="left" width="6%">级别</th>
                <th width="4%">奖金</th>
                <th width="4%">重消</th>
                <th width="5%">推荐数</th>
                <th width="5%">团队人</th>
                <th width="5%">团队额</th>
                <th width="4%">锁定</th>
                <th width="4%">停奖</th>
                <th width="4%">发展</th>
                <th width="4%">激活</th>
                <th width="4%">空点</th>
                <th width="4%">状态</th>
                <th width="6%">操作</th>
            </tr>
            @foreach (Users dr in list)
            {
        <tr>
            <td align="center">
                <span class="checkall" style="vertical-align:middle;">
                    <input type="checkbox" />
                </span>
                <label style="display:none">@dr.id</label>
            </td>
            <td>
                <div class="user-box" style="padding-left:0;">
                    <h4><b><a href="../finance_edit/index?action=@CMSEnums.ActionEnum.Edit&id=@dr.id">@dr.user_name</a></b> (昵称：@dr.nick_name)</h4>
                    <i>激活时间：@dr.pass_time?.ToString("yyyy-MM-dd hh:mm:sss")</i>
                </div>
            </td>
            @{
                var duser = _users.GetModel(dr.pid);
                var iuser = _users.GetModel(dr.iid);
                string dname = "不存在";
                string iname = "不存在";
                if (duser != null) dname = duser.user_name;
                if (iuser != null) iname = iuser.user_name;
            }
            <td>@dname</td>
            <td>@iname</td>
            <td>@dr.level_id</td>
            <td align="center">@dr.cash_point</td>
            <td align="center">@dr.shop_point</td>
            <td align="center">@dr.direct_users</td>
            <td align="center">@dr.team_users</td>
            <td align="center">@dr.team_point</td>
            <td align="center">@Html.Raw((dr.is_lock))</td>
            <td align="center">@Html.Raw((dr.is_jiangjin))</td>
            <td align="center">@Html.Raw((dr.is_share))</td>
            <td align="center">@Html.Raw((dr.is_pass))</td>
            <td align="center">@Html.Raw((dr.is_kong))</td>
            <td align="center">@(dr.status)</td>
            <td align="center"><a href="../chong_edit/index?username=@dr.user_name">充值</a></td>
        </tr>
            }
            @if (list.Count == 0)
            {
                <tr><td align="center" colspan="17">暂无会员需要审核</td></tr>
            }
        </table>

    </div>
    <!--/列表-->
    <!--内容底部-->
    <div class="line20"></div>
    <div class="pagelist">
        <div class="l-btns">
            <span>显示</span>
            <input type="text" id="txtPageNum" class="pagenum" value="@ViewBag.PageSize" onkeydown="return checkNumber(event);" onchange="search();" />
            <span>条/页</span>
        </div>
        <div class="default">@Html.Raw(ViewBag.PageContent)</div>
    </div>
    <!--/内容底部-->
</form>